﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Core.Interface;
using EzDesk.Core.ServiceImpl.Repositories;
using EzDesk.Core.ServiceImpl.Services;
using Moq;
using NUnit.Framework;
using EzDesk.Core.Model;
using CoreService = EzDesk.Core.ServiceImpl.Services.CoreService;

namespace EzDesk.Core.UnitTest
{

    /// <summary>
    /// 
    /// </summary>
    [TestFixture]
    public class CoreAppServiceFeedFixture
    {
        private ICoreService _coreService;
        
        public CoreAppServiceFeedFixture() { }

        [SetUp]
        public void Setup()
        {
            var db = new EzDeskDataContext();
            _coreService = new CoreService(
                new UserRepository(db), new DeptRepository(db), new AppRepository(db), new PositionRepository(db),
                new GroupRepository(db), new FeedRepository(db), new FeedTemplateRepository(db), new PermissionRepository(db), new OrganizationRepository(db)
                );

        }

        [Test]
        public void Test_添加一些Feed_Record然后取出来()
        {
            var testUserId1 = _coreService.GetSimpleUserInfoByUserName("yuxin").Id;
            var testUserId2 = _coreService.GetSimpleUserInfoByUserName("hxh").Id;

            var messageId1 = Guid.NewGuid();
            var templateName1 = "test_FeedTemplate1";
            var feedId1 = Guid.NewGuid();

            _coreService.SetFeedRecord(
                messageId1,
                templateName1,
                "everyone",
                feedId1,
                null
                );

            var result1 = _coreService.GetFeedRecord(messageId1, templateName1, null);
            var result2 = _coreService.GetFeedRecord(messageId1, templateName1, testUserId1.ToString());
            var result3 = _coreService.GetFeedRecord(messageId1, templateName1, testUserId1 + "," + testUserId2);

            Assert.AreEqual(result1, feedId1.ToString());
            Assert.AreEqual(result2, feedId1.ToString());
            Assert.AreEqual(result3, feedId1.ToString());
        }
    }
}
